<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\cdc;

use app\model\mongo\MongoSyncModel;
use app\service\BaseService;

final class CostSyncService extends BaseService
{
    /**
     * @var int 媒体类型
     */
    protected int $mediaId = 0;

    /**
     * @var int 任务类型
     */
    protected int $taskType = 0;

    /**
     * @var SyncService 数据同步服务
     */
    private SyncService $sync;

    /**
     * @var SyncService 数据汇总服务
     */
    private StatService $stat;

    /**
     * @param int $mediaId 媒体类型
     * @param int $taskType 任务类型  1：账户 2：视频  3：图片
     */
    public function __construct(int $mediaId = 0, int $taskType = 0)
    {
        $this->mediaId = $mediaId;
        $this->taskType = $taskType;
    }

    public function startSync(MongoSyncModel $model)
    {
        $this->sync = new SyncService($this->mediaId, $this->taskType);
        if (! $this->sync->getObject()) {
            return false;
        }

        $this->stat = new StatService($this->mediaId, $this->taskType);
        if (! $this->stat->getObject()) {
            return false;
        }

    }
}
